package cn.koala.key.stock.controller;

import cn.koala.key.stock.domain.vo.KeyInfoVO;
import cn.koala.key.stock.service.KeyInfoService;
import cn.seed.common.core.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @description:钥匙信息
 * @author 32415
 * @time 2019/04/28
 **/
@RestController
@Api(value = "KeyInfo",tags = "钥匙信息")
public class KeyInfoController {

    @Autowired
    private KeyInfoService keyInfoService;

    @ApiOperation(value = "扫码获取钥匙信息")
    @PostMapping("/key-info/scanCode")
    public Result<List<KeyInfoVO>> scanCode(@RequestBody List<String> keyBarCode,Integer status) {
        return keyInfoService.scanCode(keyBarCode,status);
    }

    @ApiOperation(value = "扫码获取钥匙信息(报废使用)")
    @PostMapping("/key-info/scraped/scanCode")
    public Result<List<KeyInfoVO>> scrapedScanCode(@RequestBody List<String> keyBarCode) {
        return keyInfoService.scrapedScanCode(keyBarCode);
    }

    @ApiOperation(value = "根据车牌和车架查在库钥匙")
    @GetMapping("/key-infos/car-vin-no")
    @Deprecated
    public Result<List<KeyInfoVO>> getByCarNoAndCarVin(String carVin, String carNo, int num) {
        return keyInfoService.getByCarNoAndCarVin(carVin, carNo, num);
    }

    @ApiOperation(value = "根据车牌和车架查钥匙")
    @GetMapping("/key-infos/car-vin-no/info")
    public Result<List<KeyInfoVO>> getByCarNoAndCarVin(String carVin, String carNo) {
        return keyInfoService.getByCarNoAndCarVin(carVin, carNo);
    }

    @ApiOperation(value = "根据车架集合查钥匙")
    @PostMapping("/key-info/car-vin/info/list")
    public Result<List<KeyInfoVO>> batchSelectKeyByCarVinList(@RequestParam MultipartFile file) {
        return keyInfoService.batchSelectKeyByCarVinList(file);
    }

}
